﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;

namespace MINERP.DAL.InfoConfig
{
    public class ProductTypeDAL:DALBase
    {
        private static ObjectQuery<tb_ProductType> GetProductTypes()
        {
            return DataEntites.tb_ProductType;
        }

        public static List<tb_ProductType> GetProductTypeList()
        {
            List<tb_ProductType> list = new List<tb_ProductType>();
            foreach (var item in GetProductTypes())
            {
                list.Add(item);
            }
            return list;
        }

        public static tb_ProductType GetProductObj(int id)
        {
            return DataEntites.tb_ProductType.First(p => p.ProductTypeId == id);
        }

        public static tb_ProductType GetProductObj(string name)
        {
            return DataEntites.tb_ProductType.First(p => p.TypeName == name);
        }

        public static void Add(tb_ProductType obj)
        {
            DataEntites.AddTotb_ProductType(obj);
            DataEntites.SaveChanges();
        }
        public static void Update()
        {
            DataEntites.SaveChanges();
        }

        public static void Delete(tb_ProductType obj)
        {
            DataEntites.DeleteObject(obj);
            DataEntites.SaveChanges();
        }
    }
}
